let py;
	if($.cookie("area")==2){
        py=[0,0]
    }else{
        py=[-2.782459,+3.9238951]
    }
	var page=1;
	var main;
    var data={};
    var fi=1;
    data.page=page;
    data.pagenum=10;
    laydate.render({
	  elem: '.time'
	  ,range: true,
	  done:function(value, date, endDate){
	  	arr = value.split(' - ')
	  	$("input[name='order_start']").val(arr[0])
	  	$("input[name='order_end']").val(arr[1])
	  }
	});
    $('#more').on('click',function(){
    	if($('#showmore').css('display')=='none'){
    		$('#showmore').css('display','block')
    	}else{
    		$('#showmore').css('display','none')
    	}
	});
	
	element.on('tab(tab1)', function(data){
		Load()
		idx =  this.getAttribute('lay-id');
		console.log(idx)
		window.location.href='/html/order/index?state='+idx
	});
	
	//获取车型
	ajax(api.carModel.typeList,{pagenum:9999},'post').done(res=>{
		var  arr=res.data;
		console.log(res)
		var options ='<option value="">全部-车型</option>';
		arr.forEach(key => {
			options += `<option {{$Think.get.car_type}==${key.car_type_id}?selected:''} value='${key.car_type_id}'>${key.car_type_name}</option>`;
		});
		$('.carType').html(options)
		form.render('select');
	})

    var where_json={};
    {if $Think.get.order_no}
		where_json.order_no=['like','%{$Think.get.order_no}%']
	{/if}
	{if $Think.get.company_name}
		where_json.company_name=['like','%{$Think.get.company_name}%']
	{/if}
	{if $Think.get.name}
		if($('.orderertype').val()==1){
			where_json.passenger_name=['like','%{$Think.get.name}%']
		}else{
			where_json.orderer=['like','%{$Think.get.name}%']
		}
	{/if}
	{if $Think.get.phone}
		where_json.passenger_phone=['like','%{$Think.get.phone}%']
	{/if}
	{if $Think.get.state}
		where_json.order_state=['in','{$Think.get.state}']
	{/if}
	{if $Think.get.order_start}
		where_json.apply_time=['between time',['{$Think.get.order_start}','{$Think.get.order_end}']]
	{/if}
	{if $Think.get.destination}
	where_json.destination=['like','%{$Think.get.destination}%']
	{/if}
	{if $Think.get.car_type}
	where_json.car_type_id=['in','{$Think.get.car_type}']
	{/if}
	{if $Think.get.meter}
	if('{$Think.get.meter}'==1){
	where_json['fee.meter']=['between',[0,100]]
	}else if('{$Think.get.meter}'==2){
	where_json['fee.meter']=['between',[100,300]]
	}else if ('{$Think.get.meter}'==3){
	where_json['fee.meter']=['>','300']		
	}
	{/if}


	data.where_json=JSON.stringify(where_json)
    ajaxorder(data)
	{if $Think.get.state==1||$Think.get.state==3||$Think.get.state==2}
		main=[[ //表头
		{field:'order_no', width:250,title: '订单号', templet: '#orderNo', fixed: 'left'}
        ,{field: 'apply_time',width:200, title: '申请时间',  sort: true}
        ,{field: 'approval_time',width:200, title: '批准时间'} 
        ,{field: 'orders_time',width:200, title: '接单时间'}
        ,{field: 'order_type2', width:100, title: '订单类型', sort: true}
        ,{field:'orderer', width:150,title:'申请人'}
        ,{field:'approval',width:150, title:'审核人'}
        ,{field:'from_addr', width:300, title:'出发地',templet: `<div>{{d.gps.to_addr?d.gps.from_addr:'-'}}</div>`}
        ,{field:'to_addr', width:300, title:'目的地',templet: `<div>{{d.gps.to_addr?d.gps.to_addr:'-'}}</div>`}
        ,{field:'use_type2',width:100, title:'用车类型'}
        ,{field:'use_explain',width:200, title:'用车说明'}
        ,{field:'order_state2', title:'订单状态'}
        {if $Think.get.state==2}
        ,{ title: '操作', width:150, toolbar:'#operation_1',fixed: 'right'}
        {else/}
        ,{ title: '操作',width:150, toolbar:'#operation_all',fixed: 'right'}
        {/if}
    ]];
	{elseif $Think.get.state==0||$Think.get.state==4||!$Think.get.state/}
	main=[[ //表头
		// {field:'order_no', width:200,title: '订单号', templet: '#orderNo', fixed: 'left'}
        // ,{field: 'apply_time', width:200, title: '申请时间',  sort: true}
        // ,{field: 'approval_time', width:200, title: '批准时间'} 
        // ,{field: 'orders_time', width:200, title: '接单时间'}
        // // ,{field: 'car_type_name', width:200, title: '车辆类型', sort: true}
        // ,{field:'order_type2', width:120, title:'订单类别'}
        // ,{field:'passenger_name', title:'乘客',templet: `<div><a href='${path.passenger.detail}?passenger_id={{d.passenger_id}}'>{{d.passenger_name?d.passenger_name:'-'}}</a><div>`}
        // ,{field:'company', title:'司机',templet: `<div><a href='${path.driver.detail}?driver_id={{d.driver.driver_id}}'>{{d.driver.name?d.driver.name:'-'}}</a><div>`}
        // ,{field:'driver_name', title:'乘客单位',templet: `<div>{{d.company.company_name?d.company.company_name:'-'}}<div>`,minWidth:230}
		// ,{field:'from_addr', width:300, title:'出发地',templet: `<div>{{d.gps.from_addr?d.gps.from_addr:'-'}}</div>`}
        // ,{field:'to_addr', width:300, title:'目的地',templet: `<div>{{d.gps.to_addr?d.gps.to_addr:'-'}}</div>`}
		// ,{field:'order_state2', title:'状态'}
		{field:'order_no', width:250,title: '订单号', templet: '#orderNo', fixed: 'left'}
        ,{field: 'apply_time',width:200, title: '申请时间',  sort: true}
        ,{field: 'approval_time',width:200, title: '批准时间'} 
        ,{field: 'orders_time',width:200, title: '接单时间'}
        ,{field: 'order_type2', width:100, title: '订单类型', sort: true}
        ,{field:'orderer', width:150,title:'申请人'}
        ,{field:'approval',width:150, title:'审核人'}
        ,{field:'from_addr', width:300, title:'出发地',templet: `<div>{{d.gps.to_addr?d.gps.from_addr:'-'}}</div>`}
        ,{field:'to_addr', width:300, title:'目的地',templet: `<div>{{d.gps.to_addr?d.gps.to_addr:'-'}}</div>`}
        ,{field:'use_type2',width:100, title:'用车类型'}
        ,{field:'use_explain',width:200, title:'用车说明'}
        ,{field:'order_state2', title:'订单状态'}
        ,{ title: '操作',width:150, toolbar:'#operation_all',fixed: 'right'}
    ]];
	{elseif $Think.get.state==5||$Think.get.state==6/}
	main=[[ //表头
		// {field:'order_no', width:200,title: '订单号', templet: '#orderNo', fixed: 'left'}
        // ,{field: 'appointment_time',width:200, title: '计划出发时间',  sort: true}
        // ,{field: 'arrive_time',width:200, title: '到达出发地时间'} 
        // ,{field: 'ride_time',width:200, title: '实际出发时间'}
        // ,{field: 'order_type2', title: '订单类型', sort: true}
        // ,{field:'passenger_name', title:'乘客'}
		// ,{field:'driver_name', title:'司机',templet: `<div>{{d.driver.name?d.driver.name:'-'}}</div>`}
		// ,{field:'driver_name', title:'乘客单位',templet: `<div>{{d.company.company_name?d.company.company_name:'-'}}<div>`,minWidth:230}
        // ,{field:'from_addr', title:'出发地',templet: `<div>{{d.gps.to_addr?d.gps.from_addr:'-'}}</div>`}
		// ,{field:'to_addr', title:'目的地',templet: `<div>{{d.gps.to_addr?d.gps.to_addr:'-'}}</div>`}
		{field:'order_no', width:250,title: '订单号', templet: '#orderNo', fixed: 'left'}
        ,{field: 'apply_time',width:200, title: '申请时间',  sort: true}
        ,{field: 'approval_time',width:200, title: '批准时间'} 
        ,{field: 'orders_time',width:200, title: '接单时间'}
        ,{field: 'order_type2', width:100, title: '订单类型', sort: true}
        ,{field:'orderer', width:150,title:'申请人'}
        ,{field:'approval',width:150, title:'审核人'}
        ,{field:'from_addr', width:300, title:'出发地',templet: `<div>{{d.gps.to_addr?d.gps.from_addr:'-'}}</div>`}
        ,{field:'to_addr', width:300, title:'目的地',templet: `<div>{{d.gps.to_addr?d.gps.to_addr:'-'}}</div>`}
        ,{field:'use_type2',width:100, title:'用车类型'}
        ,{field:'use_explain',width:200, title:'用车说明'}
        ,{field:'order_state2', title:'订单状态'}
       ,{ title: '操作',width:150, toolbar:'#operation_2',fixed: 'right'}
    ]];
    
	{else/}
	main=[[ //表头
		// {field:'order_no', width:200,title: '订单号', templet: '#orderNo', fixed: 'left'}
        // ,{field: 'ride_time',width:200, title: '计划出发时间',  sort: true}
        // ,{field: 'arrive_time',width:200, title: '到达出发地时间'} 
        // ,{field: 'ride_time',width:200, title: '实际出发时间'}
        // ,{field: 'arrive_time',width:200, title: '实际到达时间', sort: true}
        // ,{field:'order_type2', title:'订单类型'}
        // ,{field:'passenger_name', title:'乘客'}
        // ,{field:'driver_name', title:'司机',templet: `<div>{{d.driver.name?d.driver.name:'-'}}</div>`}
        // ,{field:'meter', title:'里程'}
        //  ,{field:'use_time', title:'耗时'}
        // ,{field:'passenger_money', title:'费用'}
		   // ,{field:'order_state2', title:'状态'}
		   {field:'order_no', width:250,title: '订单号', templet: '#orderNo', fixed: 'left'}
        ,{field: 'apply_time',width:200, title: '申请时间',  sort: true}
        ,{field: 'approval_time',width:200, title: '批准时间'} 
        ,{field: 'orders_time',width:200, title: '接单时间'}
        ,{field: 'order_type2', width:100, title: '订单类型', sort: true}
        ,{field:'orderer', width:150,title:'申请人'}
        ,{field:'approval',width:150, title:'审核人'}
        ,{field:'from_addr', width:300, title:'出发地',templet: `<div>{{d.gps.to_addr?d.gps.from_addr:'-'}}</div>`}
        ,{field:'to_addr', width:300, title:'目的地',templet: `<div>{{d.gps.to_addr?d.gps.to_addr:'-'}}</div>`}
        ,{field:'use_type2',width:100, title:'用车类型'}
        ,{field:'use_explain',width:200, title:'用车说明'}
        ,{field:'order_state2', title:'订单状态'}
        ,{ title: '操作',width:150, toolbar:'#operation_all',fixed: 'right'}
    ]];
	{/if}
	
	//请求订单
	function ajaxorder(data){
		Load()
		ajax(api.order.list,data,'post').done(function(res){
			
			console.log(res)
			Load(1)
			 res=orderstate(res)
					  //展示已知数据
				table.render({
				  	elem: '#order'
				    ,cellMinWidth: 80
				    ,cols: main
					,data: res.data
					,limit: data.pagenum
					,even: true
				});
				if(res.code==1){
					console.log(res)
					 if(fi==1){
						 laypage.render({
						    elem: 'page'
						    ,count: res.count
							,layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']
							,theme: '#1E9FFF'
						    ,jump: function(obj, first){
						    	if(!first){
						       		page=obj.curr
			    					data.page=page
			    					pagenum=obj.limit
			    					data.pagenum=pagenum
			    					ajaxorder(data)
		    					}else{
		    						
		    					}
						    }
						  });
						  fi=2
						 }
						//订单按钮点击
						table.on('tool(order)', function(obj){
							  var data1 = obj.data; //获得当前行数据
							  var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
							  var tr = obj.tr; //获得当前行 tr 的DOM对象
							 
							  if(layEvent === 'showmap'){ //查看
							  	var trackload = layer.load(1, {
                                    shade: [0.1, '#fff'] //0.1透明度的白色背景
                                });
                               
                                AMapUI.load(['ui/misc/PathSimplifier'], function(PathSimplifier) {
                                    
                                    
                                    ajax('{$static_dir}/assets/json/beidou_path.json',{
                                        oid: data1.order_id
                                    },'get').done(function(res){
                                        layer.close(trackload);
                                            var allpath = []
                                            var speed=0;
                                            if(typeof res == 'string') {
                                                res = JSON.parse(res)
                                            } 
                                            if(data1.order_no.substr(data1.order_no.length-1,1)%2==1){
                                            	var opath1=res[0].data
                                            }else{
                                            	var opath1=res[1].data
                                            }
                                            
                                            var opath2=[];
                                            var opath=[];
                                            //根据时间进行排序
                                            if(opath1.length>1){
                                                for(var rankidx=0;rankidx<opath1.length;rankidx++){
                                                    opath2.push(opath1[rankidx].time)
                                                }
                                                opath2.sort()
                                                for(var k=0;k<opath2.length;k++){
                                                    for(var j=0;j<opath1.length;j++){
                                                        if(opath2[k]==opath1[j].time){
                                                            opath.push(opath1[j])
                                                        }
                                                    }
                                                }
                                            
                                            for(var oi = 0; oi < opath.length; oi++) {
                                                var oarr = []
                                                oarr.push(opath[oi].longitude)
                                                oarr.push(opath[oi].latitude)
                                                allpath.push(oarr)
                                            }
                                            for(var ii=0;ii<allpath.length;ii++){
                                                allpath[ii][0]=allpath[ii][0]+(py[0]-0)
                                                allpath[ii][1]=allpath[ii][1]+(py[1]-0)
                                            }
                                            initPage(PathSimplifier, allpath,data1)
                                            }else{
                                                Err('暂无轨迹信息')
                                            }
                                    }).fail(function(){
                                        Load(1)
                                        Err('请求失败')
                                    })
                                    
                                    
                                })
							} else if(layEvent === 'changedriver'){ //删除
							   layer.open({
								    type: 1,
								    title:'订单改派',
								    skin: 'layui-layer-rim', //加上边框
								    area: ['300px', '240px'], //宽高
								    content: `<div style='padding:10px'>
								    		<form class="am-form tpl-form-border-form" data-check="1" data-ajax="1">
								    		<div class='am-u-sm-12' style='margin-bottom:10px;font-size:12px'>
								    			订单号:${data1.order_no}
								    		</div>
								    		<div class='am-u-sm-12' style='margin-bottom:10px'>
								  				<input type="hidden" class="driver_id" name="driver_id"/>
												<input type="text" class="layui-input driver_name" style="line-height: 21px;" data-department="1"  placeholder="请选择司机" readonly="" >
								  			</div>
								  			<div class='am-u-sm-12' style='margin-bottom:10px'>
								  				<input type="hidden" class="car_id" name="car_id" value="" />
												<input type="text" class="layui-input  number" value="" placeholder="请选择车辆"  readonly=""/>
								  			</div>
								  			<div class='am-u-sm-12'>
								  				<button type='button' class='layui-btn layui-btn-sm change_sub'>提交</button>
								  			</div>
								  			</form>
								  			</div>`,
								  	success:function(){
								  		$('.driver_name').on('click',function(){
											opsearch("{:url('html/plus/driver')}?op=search")
										});
										$('.number').on('click',function(){
											opsearch("{:url('/html/car/car')}?op=search")
										});
										$('.change_sub').on('click',function(){
											var driver_id=$('.driver_id').val()
											
											if($('.driver_id').val()){
												if($('.car_id').val()){
													Load()
													ajax(api.order.redispatch,{
															car_number:$('.car_number').val(),
															driver_id:$('.driver_id').val(),
															car_id:$('.car_id').val(),
															order_id:data1.order_id
														},'post').done(function(){
															Load(1)
															console.log(res)
						//									window.location.reload()
															if(res.code==1){
																Msg('改派成功')
																window.history.go(0)
															}else{
																Err(res.msg)
															}
														}).fail(function(){
															Load(1)
															Err('请求失败')
														})
													
												}else{
													Err('请选择车辆')
												}
											}else{
												Err('请选择司机')
											}
											
										});
								  	}
								});
							  } else if(layEvent === 'dispatch'){ //编辑
							 	 window.location.href= "{:url('/html/order/dispatch')}?order_id="+data1.order_id
							  } else if(layEvent === 'check'){ //编辑
								var auto = layer.open({
								type: 1,
								title:false,
								skin: 'layui-layer-rim', //加上边框
								area: ['200px', '100px'], //宽高
								content: `
									<div class='am-u-sm-12' style='padding:10px'>
										<div class='am-u-sm-12' style='text-align:center;margin-bottom:10px'>是否确认该订单</div>
										<div class='am-u-sm-12' style='text-align:center'>
											<a class='layui-btn layui-btn-sm layui-btn-primary am-radius check_ok'>审批</a>
											<a class='layui-btn layui-btn-sm layui-btn-primary am-radius close_no'>拒绝</a>
										</div>
									</div>
								`,
								success:function(){
									$('.check_ok').on('click',function(){
										Load()
										ajax(api.order.check,{
											order_id:data1.order_id,
											order_state:2,
										},'post').done((res)=>{
											Load(1)
												if(res.code==1){
													Msg('审批成功');
													window.history.go(0)
												}else{
													Err(res.msg)
												}
										}).fail(()=>{
											Load(1)
												Err('请求失败')
										})
										layer.close(auto)
									});
									$('.close_no').on('click',function(){
										layer.close(auto)
									})
								}
								})
							} 
						});
				}else{
					Err(res.msg)
				}
		}).fail(function(){
			Load(1)
				Err('请求失败')
		})
		
	}
	
//initPage(PathSimplifier, pathSimplifierIns, map, allpath)
    //轨迹
    function initPage(PathSimplifier,path, order_detail) {
    	
        order_detail.time='3小时';
        order_detail.speed='60km/h';
        AMap.plugin('AMap.Geocoder', function () {
            geocoder = new AMap.Geocoder({
                city: "010" //城市，默认：“全国”
            });
            geocoder.getAddress(path[0], function (status, result) {

                if (status === 'complete' && result.info === 'OK') {
                    //获得了有效的地址信息:
                    order_detail.from_add = result.regeocode.formattedAddress;
                } else {
                    order_detail.from_add = "获取地址失败";
                }
                geocoder.getAddress(path[1], function (status1, result1) {

                    if (status1 === 'complete' && result1.info === 'OK') {
                        //获得了有效的地址信息:
                        order_detail.to_add = result1.regeocode.formattedAddress;
                    } else {
                        order_detail.to_add = "获取地址失败";
                    }
               
                    let show_order_detail = {
                        mileage: '行驶公里数',
                        speed: '平均车速',
                        time: '用时',
                        from_add: '出发地',
                        to_add: '目的地'
                    }
                    for (var ii = 0; ii < path.length; ii++) {
                        path[ii][0] = path[ii][0] + (py[0] - 0)
                        path[ii][1] = path[ii][1] + (py[1] - 0)
                    }
                    var path_detail = ` <div class='po_absolute' style='padding:10px;z-index:9999;top:0;right:0;width:200px;height:220px;overflow:auto;background:rgba(255,255,255,0.6)'>`
                    for (var key in show_order_detail) {
                        path_detail += `<div>${show_order_detail[key]}：${order_detail[key] ? order_detail[key] :''}</div>`
                    }
                    path_detail += `</div>`
                    let navg0;
                    layer.open({
                        type: 1,
                        title: '订单轨迹回放',
                        id:'path_gj',
                        skin: 'layui-layer-rim', //加上边框
                        area: ['70%', '70%'], //宽高
                        content: `<div class='prop_map_w po_relative' style='height:100%'>
                                    ${path_detail}
                        				<div id='propmap' style='height:100%'></div>
                                        <div class="button-group">
                                            <input type="button" class="button" value="开始动画" id="start"/>
                                            <input type="button" class="button" value="暂停动画" id="pause"/>
                                                <input type="button" class="button" value="继续动画" id="resume"/>
                                            <input type="button" class="button" value="停止动画" id="stop"/>
                                        </div>
                                        <div id="progress">
                                            <div id="progress_bg">
                                                <div id="progress_bar"></div>
                                            </div>
                                            <div id="progress_btn"></div>
                                        </div>
                                    </div>`,
                        success: function () {
                            let propmap = new AMap.Map("propmap", {
                                resizeEnable: true,
                                center: path[0],
                                zoom: 10
                            });
                            //创建轨迹实例
                            //总路径

                            //正常行驶
                            let pathSimplifierIns_1 = new PathSimplifier({
                                zIndex: 100,
                                map: propmap, //所属的地图实例
                                autoSetFitView: false,
                                getPath: function (pathData, pathIndex) {
                                    //返回轨迹数据中的节点坐标信息，[AMap.LngLat, AMap.LngLat...] 或者 [[lng|number,lat|number],...]
                                    return pathData.path;
                                },
                                getHoverTitle: function (pathData, pathIndex, pointIndex) {
                                    //返回鼠标悬停时显示的信息
                                    if (pointIndex >= 0) {
                                        //鼠标悬停在某个轨迹节点上
                                        return '正常行驶<br/>速度:60km/h<br/>里程数:60km<br/>行驶时长:1小时<br/>停车时长：30分钟<br/>'
                                        // return pathData.name + '，点:' + pointIndex + '/' + pathData.path
                                        //     .length;
                                    }
                                    //鼠标悬停在节点之间的连线上
                                    // return pathData.name + '，点数量' + pathData.path.length;
                                    return '正常行驶<br/>速度:60km/h<br/>里程数:60km<br/>行驶时长:1小时<br/>停车时长：30分钟<br/>'
                                },
                                renderOptions: {
                                    //轨迹线的样式
                                    pathLineStyle: {
                                        strokeStyle: 'red',
                                        lineWidth: 6,
                                        dirArrowStyle: true
                                    }
                                }
                            });
                            //超速行驶
                            let pathSimplifierIns_2 = new PathSimplifier({
                                zIndex: 100,
                                map: propmap, //所属的地图实例
                                autoSetFitView: false,
                                getPath: function (pathData, pathIndex) {
                                    //返回轨迹数据中的节点坐标信息，[AMap.LngLat, AMap.LngLat...] 或者 [[lng|number,lat|number],...]
                                    return pathData.path;
                                },
                                getHoverTitle: function (pathData, pathIndex, pointIndex) {
                                    //返回鼠标悬停时显示的信息
                                    if (pointIndex >= 0) {
                                        //鼠标悬停在某个轨迹节点上
                                        // return pathData.name + '，点:' + pointIndex + '/' + pathData.path
                                        //     .length;
                                        return '超速行驶<br/>速度:80km/h<br/>里程数:60km<br/>行驶时长:1小时<br/>停车时长：30分钟<br/>'
                                    }
                                    //鼠标悬停在节点之间的连线上
                                    // return pathData.name + '，点数量' + pathData.path.length;
                                    return '超速行驶<br/>速度:80km/h<br/>里程数:60km<br/>行驶时长:1小时<br/>停车时长：30分钟<br/>'
                                },
                                renderOptions: {
                                    //轨迹线的样式
                                    pathLineStyle: {
                                        strokeStyle: 'orange',
                                        lineWidth: 6,
                                        dirArrowStyle: true
                                    }
                                }
                            });
                            let pathSimplifierIns_all = new PathSimplifier({
                                zIndex: 100,
                                map: propmap, //所属的地图实例
                                getPath: function (pathData, pathIndex) {
                                    //返回轨迹数据中的节点坐标信息，[AMap.LngLat, AMap.LngLat...] 或者 [[lng|number,lat|number],...]
                                    return pathData.path;
                                },
                                getHoverTitle: function (pathData, pathIndex, pointIndex) {
                                    //返回鼠标悬停时显示的信息
                                    if (pointIndex >= 0) {
                                        //鼠标悬停在某个轨迹节点上
                                        // return pathData.name + '，点:' + pointIndex + '/' + pathData.path
                                        //     .length;
                                    }
                                    //鼠标悬停在节点之间的连线上
                                    // return pathData.name + '，点数量' + pathData.path.length;
                                },
                                renderOptions: {
                                    //轨迹线的样式
                                    pathLineStyle: false
                                }
                            });
                            let path1 = [], path2 = []
                            for (let i = 0; i < path.length; i++) {
                                if (i < path.length / 2) {
                                    path1.push(path[i])
                                } else {
                                    path2.push(path[i])
                                }
                            }
                            // 

                            pathSimplifierIns_1.setData([{
                                name: '轨迹0',
                                path: path1
                            }]);
                            pathSimplifierIns_2.setData([{
                                name: '轨迹0',
                                path: path2
                            }]);
                            pathSimplifierIns_all.setData([{
                                name: '轨迹0',
                                path: path
                            }]);
                            //创建一个巡航器
                            navg0 = pathSimplifierIns_all.createPathNavigator(0, //关联第1条轨迹
                                {
                                    loop: false, //循环播放
                                    speed: 1000,
                                    content: PathSimplifier.Render.Canvas.getImageContent('{$static_dir}/assets/img/car-red.png', onload, onerror)
                                });

                            // 轨迹更能按钮
                            navg0.start();
                            $('#start').on('click', function () {
                                navg0.start()
                            });
                            $('#pause').on('click', function () {
                                navg0.pause()
                            });
                            $('#resume').on('click', function () {
                                navg0.resume()
                            });
                            $('#stop').on('click', function () {
                                navg0.stop()
                            });
                            navg0.on('move', function () {
                                let left = (navg0.getCursor().idx / path.length) * 300
                                $('#progress_btn').css('left', left);
                                $('#progress_bar').css('width', left);
                            })


                            //拖动
                            //滚动条
                            let tag = false,
                                ox = 0,
                                left = 0,
                                bgleft = 0
                            AMap.event.addDomListener(document.getElementById('progress_btn'), 'mousedown',
                                function (e) {
                                    ox = e.pageX - left;
                                    tag = true;
                                }, false);
                            $(document).mouseup(function () {
                                tag = false;
                            });
                            AMap.event.addDomListener(document.getElementById('progress'), 'mousemove',
                                function (e) {
                                    if (tag) {
                                        left = e.pageX - ox;
                                        if (left <= 0) {
                                            left = 0;
                                        } else if (left > 300) {
                                            left = 300;
                                        }
                                        $('#progress_btn').css('left', left);
                                        $('#progress_bar').width(left);
                                        let num = Math.floor(left / tip) - 1;
                                        if (num < 0) {
                                            num = 0
                                        } else {
                                            num = Math.ceil(left / tip);
                                        }
                                        let progress_br = left / 300

                                        navg0.moveToPoint(parseInt(path.length * progress_br))
                                    }
                                }, false);
                            AMap.event.addDomListener(document.getElementById('progress_bg'), 'click', function (
                                e) {
                                if (!tag) {
                                    bgleft = $('#progress_bg').offset().left;
                                    left = e.pageX - bgleft;
                                    if (left <= 0) {
                                        left = 0;
                                    } else if (left > 300) {
                                        left = 300;
                                    }
                                    $('#progress_btn').css('left', left);
                                    $('#progress_bar').animate({
                                        width: left
                                    }, 300);
                                    let progress_br = left / 300
                                    navg0.moveToPoint(parseInt(path.length * progress_br))
                                }
                            }, false);
                            // 

                        }, end: function (index, layero) {
                            navg0.destroy()
                        }
                    })
                });
            });

        })



    }
	
	
	
	